package com.validated;

import com.validated.annotation.Digits;
import com.validated.annotation.NotNull;
import com.validated.annotation.Phone;
import com.validated.validator.ParameterValidator;
import com.validated.validator.ParameterValidatorImpl;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

public class Main {

    public static void main(String[] args) {
        ParameterValidator validator = new ParameterValidatorImpl();
        User user = new User();
        user.setName("aaaaa");
        user.setPhone("19234877766");
        user.setAge(null);

        try {
            validator.entityValid(user);
        }catch (Exception e){
            System.out.println(e.getMessage());
        }
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    static public class User{
        @NotNull(msg = "名字不能为空")
        private String name;

        @Phone(msg = "手机错误")
        private String phone;

        @Digits(msg = "年龄格式不正确")
        private String age;
    }

}
